#include<iostream>
#include<vector>
#include<queue>

using namespace std;

typedef struct TreeNode
{
    int val;
    struct TreeNode* left;
    struct TreeNode* right;
}TreeNode;

class Solution {
public:
    vector<vector<int>> levelOrder(TreeNode* root) {
        vector<vector<int>> vv;
        queue<TreeNode*> q;
        size_t nodesize = 0;
        if (root)
        {
            q.push(root);
            nodesize = 1;
        }

        while (!q.empty())
        {
            vector<int> v;
            while (nodesize--)
            {
                TreeNode* front = q.front();
                q.pop();
                v.push_back(front->val);

                if (front->left)
                {
                    q.push(front->left);
                }

                if (front->right)
                {
                    q.push(front->right);
                }
            }

            vv.push_back(v);
            nodesize = q.size();
        }
        return vv;
    }
};

int main()
{
    return 0;
}